import cv2 as cv
import numpy as np


def main():
    original_img = np.zeros((300, 300, 3), np.uint8)
    original_img[100:200, 100:200] = 255
    gray_img = cv.cvtColor(original_img, cv.COLOR_BGR2GRAY)
    ret, thresh_img = cv.threshold(gray_img, 127, 255, 0)
    contours, hierarchy = cv.findContours(thresh_img, cv.RETR_TREE, cv.CHAIN_APPROX_NONE)
    print(contours)
    contour_img = np.zeros((300, 300, 3), np.uint8)
    cv.drawContours(contour_img, contours, 0, (0, 0, 255), 1)
    cv.imshow('Original', original_img)
    cv.imshow('Contours', contour_img)
    cv.waitKey(0)
    cv.destroyAllWindows()


if __name__ == "__main__":
    main()
